package bookez.model.businessobject;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@NamedQueries ({
		
	@NamedQuery (
		name 	= "BusType.findAll",
		query 	= "from BusType"		
	),//end NamedQuery findAll
	
	@NamedQuery (
		name 	= "BusType.findByName",
		query 	= "from BusType as busType where busType.name = :name"
	),
})//end collecions of NamedQuery


@Entity
@Table ( name = "bustype" )
public class BusType extends BusinessObject implements Serializable {
	
	public static class NamedQueries {
		public static final String FIND_ALL = "BusType.findAll";
		public static final String FIND_BY_NAME = "BusType.findByName";
	}//end section NamedQueries
	
	
	
	
	public BusType() { };//end default constructor
	
	@Id
	@GeneratedValue
	public Long getId() { return this.id; }
	public void setId( Long value ) { this.id = value; }	
	
	@Column ( name = "type_name", nullable = false )
	public String getName() { return this.name; }
	public void setName( String value ) { this.name = value; }
	
	@Column ( name = "seat_type", nullable = false )
	public String getSeatType() { return this.seatType; }
	public void setSeatType( String value ) { this.seatType = value; }
	
	@Column ( name = "seat_count", nullable = false )
	public int getSeatCount() { return this.seatCount; }
	public void setSeatCount( int value ) { this.seatCount = value; }
	
	
	@Override
	protected boolean blindlyEquals(Object obj) {
		// TODO Auto-generated method stub
		if( !(obj instanceof BusType ) 	) { return false; }
		
		final BusType other = (BusType) obj;
		
		boolean nameChecked = checkProperty( this.getName(), other.getName());
		boolean seatTypeChecked = checkProperty( this.getSeatType(), other.getSeatType() );
		boolean seatCountChecked = checkProperty( this.getSeatCount(), other.getSeatCount() );
		
		boolean[] results = new boolean[] { nameChecked, seatTypeChecked, seatCountChecked };
		
		return processResult( results );
	}//end method blindlyEquals
	
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		addPropertyToHashCode( getName() );
		addPropertyToHashCode( getSeatType() );
		addPropertyToHashCode( getSeatCount() );
		return toHashCode();
	}//end method hashCode
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		addInfo( "id", getId());
		addInfo( "name", getName() );
		addInfo( "seatType", getSeatType() );
		addInfo( "seatCount", getSeatCount() );
		return createInfo();
	}//end method toString

	// Instance variables
	private Long id;
	private String name;
	private String seatType;
	private int seatCount;	
	
	private static final long serialVersionUID = 8736272721188637511L;

}//end class BusType
